import http from "@/api";

import { ModuleCommonUrl, ModuleFlexJobUrl } from "..";
import { DealerInfoEntity, DealerUserVo } from "@/biz/interface/modules/DealerType";
import { ResPage } from "@/api/interface";

const moduleUrl = ModuleFlexJobUrl;

const moduleComUrl = ModuleCommonUrl;

// * 保存接口
export const saveDealerApi = (dealer: {}) => {
  return http.post(moduleUrl + `/cpy/infosave`, dealer);
};

// * 详情接口
export const getDealerInfoApi = (params: {}) => {
  return http.post<DealerInfoEntity>(moduleUrl + `/dealapi/basicinfo`, params);
};

// * 生成邀请码
export const getDealerInviteCodeApi = () => {
  return http.post(moduleUrl + `/dealcpyapi/geninvitecode`, {});
};

// * 获取企业字典值
export const getCompanySysDataApi = () => {
  return http.post(moduleComUrl + `/comapi/dictionary`, { tbName: "cpy" });
};

// * 获取经销商钱包接口
export const getWalletInfoByDealerApi = () => {
  return http.post(moduleUrl + `/dealwalletapi/walletinfo`, {});
};

// * 获取订单表列表
export const getDealerUsersVoListApi = (params: { dealerId: string }) => {
  return http.post<ResPage<DealerUserVo>>(moduleUrl + `/dealeruserapi/users`, { ...params });
};

// * 删除位置关联的一条记录
export const deleteDealerUserApi = (params: { id: string }) => {
  return http.post(moduleUrl + `/dealeruserapi/usrdelete`, params);
};

// 保存经销商的用户
export const saveDealerUserApi = (params: {}) => {
  return http.post(moduleUrl + `/dealeruserapi/usrsave`, params);
};

export const getDealerUserInfoApi = (params: { id: string }) => {
  return http.post(moduleUrl + `/dealcpyapi/geninvitecode`, { ...params });
};
